<?php
//echo 'tes aja'; exit;

    foreach ($getDetail as $row1) {
        $vnik 		= $row1['USRUPD'];
		$vname 		= $row1['NAME'];
		$vorg 		= $row1['ORG'];
		$vjob		= $row1['JOB_POSITION'];
		$viscard	= $row1['ISCARD'];
		$vistelp	= $row1['ISTELP'];
		$vusefor	= $row1['USE_FOR'];
		$vvendor	= $row1['VENDOR'];
		$vusername	= $row1['USER_NAME'];
		$vdtmupd	= $row1['DTMUPD'];
		$vdesc		= $row1['CTRL_DESCRIPTION'];
		$vdate1	    = $row1['CTRL_DATE_AWAL'];
		$vdate2	    = $row1['CTRL_DATE_AKHIR'];
		$vtime1	    = $row1['CTRL_HOUR_AWAL'];
		$vtime2	    = $row1['CTRL_HOUR_AKHIR'];
		$vAtasanNik	= $row1['CTRL_ATASAN_ID'];
		$vphonefisik= $row1['CTRL_TELP_FISIK'];
		$vcardfisik	= $row1['CTRL_CARD_FISIK']; 
		$vAtasanName= $row1['NAMA_ATASAN'];
		$vfile		= $row1['CTRL_FILE'];
		$vfilename	= $row1['CTRL_FILENAME'];
    }
    
    //var_dump($row1);exit;
    $str_acc_ctrl = '';
    foreach ($getFloor as $row2) {
    	$str_acc_ctrl .= $row2['CARD_FLOOR_NAME'].', ';
    }
    $str_acc_ctrl = substr($str_acc_ctrl,0,-2);
    
    //echo $str_acc_ctrl;exit;
    foreach ($getFloor2 as $row3) {
	   $str_line_telp .= $row3['TELP_EXT_EXT_TYPE'].', ';
       //$pKey 	= $row['TELP_EXT_EXT_TYPE'];
	   //echo "$pKey &nbsp;&nbsp";
    }
    $str_line_telp = substr($str_line_telp,0,-2);
?>

<script>
    function cancel() {
        $.post("<?= site_url() ?>search_global", function(data) {
            window.location = '<?php echo base_url(); ?>search_global';
        });
    }
    function appGaSave() {
        $.post("<?= site_url() ?>search_global/approve_gaSave", {
            pCtrlID: $('#pCtrlID').val(),
            pApproval: $('#pApproval').val(),
            pComment: $('#pComment').val(),
            pAccesNo: $('#pAccesNo').val()
        },
        function(data) {
            window.location = '<?php echo base_url(); ?>search_global';
        });
    }
</script>


<form id="formarea" role="form" method="post" action="#">
<div class="col-md-offset-0" id="top">
    <div class="col-md-11">
        <div class="panel panel-default">
			<div class="panel-heading">
			<h4 class="panel-title"><b> Requestor </b></h4>
			</div>
			<div class="panel-body">
            <input type="hidden" value="<?php echo $cRequestNo; ?>" id="pCtrlID" />
                <div class="row"> 
                    <div class="col-sm-12">
                        <div class="form-group">
                            <label class="control-label col-md-3">Access Control</label>
    						<div class="col-md-9"><?php echo $str_acc_ctrl;?></div>
				        </div>
                    </div>                   
                </div>
                <div class="row"> 
                    <div class="col-sm-12">
                        <div class="form-group">
                            <label class="control-label col-md-3">Line Telp</label>
    						<div class="col-md-9"><?php echo $$vistelp==1?'Yes':'No' ?></div>
				        </div>
                    </div>                   
                </div>
                <div class="row"> 
                    <div class="col-sm-12">
                        <div class="form-group">
                            <label class="control-label col-md-3">Fasilitas Line Telp</label>
    						<div class="col-md-9"><?php echo $str_line_telp; ?></div>
				        </div>
                    </div>                   
                </div>
                <div class="row"> 
                    <div class="col-sm-12">
                        <div class="form-group">
                            <label class="control-label col-md-3">ID Card</label>
    						<div class="col-md-9"><?php echo $vcardfisik=='1'?'Yes':'No'; ?></div>
				        </div>
                    </div>                   
                </div>
                <div class="row"> 
                    <div class="col-sm-12">
                        <div class="form-group">
                            <label class="control-label col-md-3">Fixed Phone</label>
    						<div class="col-md-9"><?php echo $vphonefisik; ?></div>
				        </div>
                    </div>                   
                </div>
                <div class="row"> 
                    <div class="col-sm-12">
                        <div class="form-group">
                            <label class="control-label col-md-3">Use For</label>
    						<div class="col-md-9"><?php echo $vusefor; ?></div>
				        </div>
                    </div>                   
                </div>
                <div class="row"> 
                    <div class="col-sm-12">
                        <div class="form-group">
                            <label class="control-label col-md-3">Vendor Name</label>
    						<div class="col-md-9"><?php echo $vvendor; ?></div>
				        </div>
                    </div>                   
                </div>
                <div class="row"> 
                    <div class="col-sm-12">
                        <div class="form-group">
                            <label class="control-label col-md-3">Person</label>
    						<div class="col-md-9"><?php echo $vusername; ?></div>
				        </div>
                    </div>                   
                </div>
                <div class="row"> 
                    <div class="col-sm-12">
                        <div class="form-group">
                            <label class="control-label col-md-3">Periode</label>
    						<div class="col-md-9"><?php echo "$vdate1 &nbsp;s/d&nbsp; $vdate2" ; ?></div>
				        </div>
                    </div>                   
                </div>
                <div class="row"> 
                    <div class="col-sm-12">
                        <div class="form-group">
                            <label class="control-label col-md-3">Jam Pemakaian</label>
    						<div class="col-md-9"><?php echo "$vtime1 &nbsp;s/d&nbsp; $vtime2" ; ?></div>
				        </div>
                    </div>                   
                </div>
                <div class="row"> 
                    <div class="col-sm-12">
                        <div class="form-group">
                            <label class="control-label col-md-3">Tgl Request Order</label>
    						<div class="col-md-9"><?php echo $vdtmupd; ?></div>
				        </div>
                    </div>                   
                </div>
                <div class="row"> 
                    <div class="col-sm-12">
                        <div class="form-group">
                            <label class="control-label col-md-3">File Uploaded</label>
    						<div class="col-md-9"><a href="<?php echo !empty($vfilename)?"upload/$vfilename":""; ?>" target="_blank" <?php if(empty($vfilename)) echo 'onclick="return false;"'; ?>>
                            <?php echo $vfile; ?> </a>
                            </div>
				        </div>
                    </div>                   
                </div>
                <div class="row"> 
                    <div class="col-sm-12">
                        <div class="form-group">
                            <label class="control-label col-md-3">Description</label>
    						<div class="col-md-4">
                                <textarea class="form-control input-sm" name="pComment"><?php echo $vdesc; ?></textarea>
    						</div>
				        </div>
                    </div>                   
                </div>
                <div class="row"> 
                    <div class="col-sm-12">
                        <div class="form-group">
                            <label class="control-label col-md-3">Nama Atasan</label>
    						<div class="col-md-9"><?php echo $vAtasanName ; ?></div>
				        </div>
                    </div>                   
                </div>
                <div class="row"> 
                    <div class="col-sm-12">
                        <div class="form-group">
                            <label class="control-label col-md-3">Comment</label>
    						<div class="col-md-4">
                                <textarea class="form-control input-sm" id="pComment"></textarea>
    						</div>
				        </div>
                    </div>                   
                </div>
                <div class="row"> 
                    <div class="col-sm-12">
                        <div class="form-group">
                            <label class="control-label col-md-3">Approval</label>
    						<div class="col-md-4">
                                <select class="form-control input-form select2" id="pApproval" style="width:100%">
                        			<option value="Y">Approve</option>
                                    <option value="N" selected="">Disapprove</option>
				                </select>
    						</div>
				        </div>
                    </div>                   
                </div>
                
                <div class="row"> 
                    <div class="col-sm-12">
                        <div class="form-group">
                            <label class="control-label col-md-3"></label>
				        </div>
                    </div>                   
                </div>
                <div class="row"> 
                    <div class="col-sm-12">
                        <div class="form-group">
                            <label class="control-label col-md-3"></label>
    						<div class="col-sm-2">
                                <button type="button" class="btn btn-primary btn-block" onclick="appGaSave();">Submit</button>
                            </div>
                            <div class="col-sm-2">
                                <button type="button" class="btn btn-default btn-block" onclick="cancel();" >Cancel</button>
                            </div>
				        </div>
                    </div>                   
                </div>
                
            </div>
        </div>
    
    </div>
</div>
</form>